package com.wensi.eventbus

import org.greenrobot.eventbus.EventBus
import java.util.*

/** eventbus 管理 */
object EventManager {
    // 注册
    fun register(subscriber: Any) {
        EventBus.getDefault().register(subscriber)
    }

    // 解绑
    fun unRegister(subscriber: Any) {
        EventBus.getDefault().unregister(subscriber)
    }

    // 发送事件类
    private fun post(event: MessageEvent) {
        EventBus.getDefault().post(event)
    }
    // 发送事件类型
    fun post(type: Int) {
        post(MessageEvent((type)))
    }

    // 发送类型携带string
    fun post(type: Int, string: String) {
        val event = MessageEvent(type)
        event.stringValue = string
        post(event)
    }// 发送类型携带int
    fun post(type: Int, int: Int) {
        val event = MessageEvent(type)
        event.intValue = int
        post(event)
    }// 发送类型携带boolean
    fun post(type: Int, bol: Boolean) {
        val event = MessageEvent(type)
        event.booleanValue = bol
        post(event)
    }
}